Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very simple version of ReshapeLayer #2088

Closed
wants to merge 1 commit into from

Conversation

jeffdonahue
Copy link
Contributor

(Cherry-picked from my RNN PR -- #2033)

This is a version of ReshapeLayer that just takes a BlobShape and reshapes its input to be that shape. It doesn't have any of the options from #108 or #1263 (infer special defaults when dim is set to 0 or 1 for some axes), but works with the new ND blobs (#1970), and I think the added options to FlattenLayer in #2082 satisfy a lot of the use cases of those options. But I'm happy to see those options added later, or maybe this shouldn't be merged without them? (I was originally in favor of replacing FlattenLayer with ReshapeLayer altogether, but the implementations are very light (all in SetUp), and I now think it's probably more intuitive just to call a "flatten" layer than figuring out the special dimension values for reshape layer to get the equivalent output.)

template <typename Dtype>
void ReshapeLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
top[0]->Reshape(this->layer_param_.reshape_param().shape());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@longjon I guess this should technically all be done in LayerSetUp since the top shape doesn't vary with the bottom shape? (But then if special options were added when certain dims of the shape are set to 0 or -1, the top would then vary with the bottom shape, so it would be moved to Reshape then? Maybe better to keep it in Reshape then?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, to me it feels like this should go in LayerSetUp. If special options were added so that top shape depended on bottom shape, then Reshape would be needed. But that isn't the case in this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed. I kept the CHECK_EQ for counts in Reshape though, which still seems right.

myfavouritekk added a commit to myfavouritekk/caffe that referenced this pull request Mar 25, 2015
Very simple version of ReshapeLayer

* jeffdonahue/simple-reshape-layer:
  Add (very simple version of) ReshapeLayer
@jeffdonahue
Copy link
Contributor Author

replaced by #2217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants